MPI_COMPILE_FLAGS = $(shell mpicc --showme:compile) 
MPI_LINK_FLAGS = $(shell mpicc --showme:link) -fopenmp -lm

all:
	g++-4.2 -o main $(MPI_LINK_FLAGS) $(MPI_COMPILE_FLAGS) main.cpp
	
run:
	mpirun -np 14 --hostfile hosts main



teste:  
	mpiCC -o main_teste $(MPI_LINK_FLAGS) $(MPI_COMPILE_FLAGS) main_teste.cpp

run_teste: teste
	time mpirun -np 2 main_teste palavras.txt 10
	time mpirun -np 2 main_teste palavras.txt 10
	time mpirun -np 2 main_teste palavras.txt 10
	time mpirun -np 2 main_teste palavras.txt 10
	time mpirun -np 2 main_teste palavras.txt 10

run_p: teste
	time mpirun -np 7 main_teste palavras.txt 1
	time mpirun -np 7 main_teste palavras.txt 1
	time mpirun -np 7 main_teste palavras.txt 1
	time mpirun -np 7 main_teste palavras.txt 1
	time mpirun -np 7 main_teste palavras.txt 1
	time mpirun -np 7 main_teste palavras.txt 2
	time mpirun -np 7 main_teste palavras.txt 2
	time mpirun -np 7 main_teste palavras.txt 2
	time mpirun -np 7 main_teste palavras.txt 2
	time mpirun -np 7 main_teste palavras.txt 2
	time mpirun -np 7 main_teste palavras.txt 5
	time mpirun -np 7 main_teste palavras.txt 5
	time mpirun -np 7 main_teste palavras.txt 5
	time mpirun -np 7 main_teste palavras.txt 5
	time mpirun -np 7 main_teste palavras.txt 5


teste2:  
	mpiCC -o main_teste2nos $(MPI_LINK_FLAGS) $(MPI_COMPILE_FLAGS) main_teste_2_nos.cpp

run_teste2: teste
	time mpirun -np 2 main_teste2nos palavras.txt 10
	time mpirun -np 2 main_teste2nos palavras.txt 20
	time mpirun -np 2 main_teste2nos palavras.txt 30
	time mpirun -np 2 main_teste2nos palavras.txt 40
	time mpirun -np 2 main_teste2nos palavras.txt 50
	time mpirun -np 2 main_teste2nos palavras.txt 60
	time mpirun -np 2 main_teste2nos palavras.txt 70
	time mpirun -np 2 main_teste2nos palavras.txt 80
	time mpirun -np 2 main_teste2nos palavras.txt 90
	time mpirun -np 2 main_teste2nos palavras.txt 100
